package 序列化;

import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Seria implements Serializable {
	private static final long serialVersionUID = -1602952864698921314L;
	public int getValue(){
		return 100;
	}
	public int getValue2(int a){
		return a;
	}
	public Person getPerson(Person p){
		return p;
	}
	
	public static void main(String[] args) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
		Seria seria=new Seria();
		Method method=seria.getClass().getMethod("getValue");
		Object obj=method.invoke(seria);
		System.out.println(obj);
		Method method2=seria.getClass().getMethod("getValue2", int.class);
		Object obj2=method2.invoke(seria,300);
		System.out.println(obj2);
		
		Method method3=seria.getClass().getMethod("getPerson", Person.class);
		
		Object p=method3.invoke(seria, new Seria().new Person(111,"tom"));
		System.out.println(p.toString());
		
	}
	class Person{
		int age;
		String name;
		
		public Person(int age, String name) {
			super();
			this.age = age;
			this.name = name;
		}
		public int getAge() {
			return age;
		}
		public void setAge(int age) {
			this.age = age;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		@Override
		public String toString() {
			return "Person [age=" + age + ", name=" + name + "]";
		}
		
		
	}
}
